$(function(){
var oUser1=$("#zl-ip2");
var oPass1=$("#zl-ipt1");
var oBtn=$('.zl-btn');
var oA1=$('.a1');
var oA2=$('.a2');
var oSp=$('#sp1');
var oSp1=$('#sp2');

$('#exampleModal').on('show.bs.modal', function (event) {
    var button = $(event.relatedTarget)
    var recipient = button.data('whatever')
    var modal = $(this)
    modal.find('.modal-title').text('New message to ' + recipient)
    modal.find('.modal-body input').val(recipient)

})
    var json={
    "aUser":[{"user":"aaa","pass":"111","type":1}]
    }
    var str=JSON.stringify(json);
localStorage.setItem('data',str);
    oBtn.click(
        function(){
         var data=JSON.parse(localStorage.getItem('data'));
            var aUser=json.aUser;
         var sName=oUser1.val();
         var sPass=oPass1.val();
      for(var i=0;i<aUser.length;i++){
          if(aUser[i].user==sName){
              if(aUser[i].pass==sPass){
                  $('#a3')[0].href+='?type='+aUser[i].type;
                  $('#a3')[0].click();
                  return;
              }else {
                  alert("账号或密码错误");
                  return;
              }
          }
      }
      alert("账号错误");
        }

    )

    oUser1.onblur=function(){
        var str=this.value;

        var reg=/^[a-z]{2,12}$/;

        if(reg.test(str)){

        }else{
            oSp.text('您输入的账号格式有误');


        }
    }
    oUser1.onfocus=function(){
        oSp.text(" ")   ;
    }

   })

